package com.example.qxfw.dlqx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.qxfw.common.entity.zy.PowerLoadHour;
import com.example.qxfw.dlqx.mapper.PowerLoadHourMapper;
import com.example.qxfw.dlqx.service.PowerLoadHourService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class PowerLoadHourServiceImpl implements PowerLoadHourService {

    @Autowired
    private PowerLoadHourMapper powerLoadHourMapper;

    @Override
    public List<PowerLoadHour> getMaxTime() {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.select("max(datechar) as datechar");
        return powerLoadHourMapper.selectList(queryWrapper);
    }

    @Override
    public List<PowerLoadHour> listByParams(String dateChar1, String dateChar2) {
        return powerLoadHourMapper.selectByDateChar(dateChar1,dateChar2);
    }

    @Override
    public List<PowerLoadHour> listByParams1(String dateChar1, String dateChar2) {
        return powerLoadHourMapper.selectList(Wrappers.<PowerLoadHour>lambdaQuery()
                .between(PowerLoadHour::getDatechar, Timestamp.valueOf(dateChar1),Timestamp.valueOf(dateChar2)));
    }
}
